package com.andy.controller;

import com.alibaba.cloud.nacos.discovery.NacosDiscoveryClient;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.andy.service.PruductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

/**
 * @packageName: com.andy.controller
 * @user: andyliu
 * @date: 2021/9/4 17:59
 * @email 115176513@qq.com
 * @description: TODO
 */

@RestController
@RequestMapping("consumer")
public class ConsumerController {

    @Autowired
   private PruductService service;

    @RequestMapping("/info/{pid}")
    @SentinelResource("cus_method1")
    public String getProductInfo(@PathVariable String pid){
        return service.getProductId(pid);
    }

    @RequestMapping("/info2/{pid}")
    @SentinelResource("cus_method2")
    public String getProductInfo2(@PathVariable String pid){
        return service.getProductId(pid);
    }


}
